package org.kernely.security.ui;

import org.kernely.security.ui.Activator;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.event.EventAdmin;
import org.osgi.service.http.HttpService;


public class Activator implements BundleActivator {


	/**
	 * Called when the bundle is STARTING
	 */
	public void start(BundleContext pBundleContext) throws Exception {
		// retrieve the Apache Log service
		//	    ServiceReference ref2 = pBundleContext.getServiceReference(LogService.class.getName());
		//		if (ref2 != null)
		//		{
		//			LogService log = (LogService) pBundleContext.getService(ref2);
		//			SecurityUIBundle.setLog(log);
		//		}
		ServiceReference sRef = pBundleContext.getServiceReference(HttpService.class.getName());
		if (sRef != null)
		{
			HttpService service = (HttpService) pBundleContext.getService(sRef);
			service.registerResources("/securityUIbundle/images", "icon", null);
		}

		
		// Event admin, to send/receive events

		ServiceReference ref = pBundleContext.getServiceReference(EventAdmin.class.getName());
		if (ref != null)
		{
			EventAdmin eventAdmin = (EventAdmin) pBundleContext.getService(ref);

			SecurityUIBundle.setEventAdminService(eventAdmin);
		}

	}

	/**
	 * Called when the Bundle is STOPPING
	 */
	public void stop(BundleContext arg0) throws Exception {
	}




}
